1 Robot Operating System (ROS 2) - Installation

Virtualbox vs Dual boot vs Install Windows Subsystem for Linux (WSL)

Feature / Criteria VirtualBox Dual Boot (Ubuntu + Windows) WSL (Windows Subsystem for Linux 2)
Performance Moderate (virtualization overhead, slower graphics & I/O) High (runs directly on hardware, best performance) High for CPU-bound tasks; GPU support improving but still limited compared to native Linux
Ease of Setup Moderate (need VirtualBox, ISO, setup guest additions) Complex (partitioning, bootloader setup, risk of mistakes) Easy (install via Microsoft Store, enable WSL2, install Ubuntu/Debian)
Resource Usage High (VM needs dedicated RAM, CPU, disk space) Efficient (uses hardware directly) Low/Moderate (shares Windows resources, no full duplication of OS)
Hardware Access (GPU, USB, Sensors, Cameras, etc.) Limited (USB pass-through possible, GPU support weak) Full (direct access to all hardware) Limited but improving (CUDA, DirectML, OpenGL supported in WSLg; hardware drivers not always stable)
Networking NAT/Bridged (sometimes config needed for ROS multi-machine setups) Native (no issues) Works with localhost, some complexity in ROS multi-machine networking
ROS 2 Compatibility Good (Ubuntu VM runs ROS 2 natively) Excellent (native Ubuntu environment) Good (ROS 2 runs, GUI via WSLg, but some packages requiring real-time hardware drivers may fail)
GUI / RViz / Gazebo Works but slow (requires 3D acceleration support, may lag) Excellent (native GPU acceleration) Works with WSLg (much better now, but may lag for heavy 3D sim like Gazebo)
Maintenance & Updates Easy to reset VM snapshots, isolated environment More effort (dual OS updates, potential bootloader issues) Easy (managed as Windows app, update via apt + Windows Store)
Best Use Case Beginners, testing ROS 2 without touching main OS Developers needing max performance, hardware integration, robotics projects Windows users who want ROS 2 for learning, coding, and light simulation without leaving Windows

****It is strongly recommended to use a dual-boot setup; however, please be aware of the risks and make sure to back up your entire hard drive beforehand!!!

Kindly download these files:
(1) VBox -https://www.virtualbox.org/wiki/Downloads ;
(2) Ubuntu 22.04 LTS (Jammy Jellyfish)- (4 GB) https://releases.ubuntu.com/jammy/ubuntu-22.04.5-desktop-amd64.iso

Install Virtual Box

  • Step 1
    Pasted image 20250925160549.png

  • Step 2 **make sure uncheck "Skip Unattended Installation"

Pasted image 20250925160700.png

  • Step 3:
    Pasted image 20250925160800.png

Pasted image 20250925162415.png

Pasted image 20250925162425.png

Pasted image 20250925162556.png

Pasted image 20250925162614.png

Pasted image 20250925162633.png

Pasted image 20250925162736.png

Pasted image 20250925162745.png

Pasted image 20250925162752.png
Pasted image 20250925162758.png
Pasted image 20250925162805.png
Pasted image 20251002112845.png

Pasted image 20251002112852.png

Enable Copy & Paste Function

Pasted image 20251002112900.png

Pasted image 20251002112906.png

Pasted image 20251002112914.png

  • Open new terminal (Ctr + Alt + T)
whoami
sudo adduser $USER vboxsf
sudo reboot

ROS 2 Installation

  • Open new terminal (Ctr + Alt + T) -Update and Upgrade Ubuntu apt repository
sudo apt update && sudo apt upgrade
  • Setup Locale
sudo apt update && sudo apt install locales -y
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
  • Add ROS 2 Repository
sudo apt install software-properties-common -y
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
  • Add the repository to sources list:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \
http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" \
| sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
  • update system again
sudo apt update
  • Define ROS Distribution Variable
echo '# ROS 2 setup' >> ~/.bashrc
echo 'export ROS_DISTRO=humble' >> ~/.bashrc
  • reload the shell
source ~/.bashrc
  • install ROS
sudo apt install ros-$ROS_DISTRO-desktop python3-argcomplete -y
  • install ROS -dev
sudo apt install ros-dev-tools -y
  • Environment Setup
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc
  • add shortcut cmds
echo "alias eb='nano ~/.bashrc'" >> ~/.bashrc
echo "alias sb='source ~/.bashrc'" >> ~/.bashrc
echo "alias gs='git status'" >> ~/.bashrc
echo "alias gp='git pull'" >> ~/.bashrc
echo "alias cw='cd ~/ros2_ws'" >> ~/.bashrc
echo "alias cs='cd ~/ros2_ws/src'" >> ~/.bashrc
echo "alias cb='cd ~/ros2_ws && colcon build --symlink-install'" >> ~/.bashrc
echo "alias sb='source ~/ros2_ws/install/setup.bash'" >> ~/.bashrc
echo "alias sj='source /opt/ros/humble/setup.bash'" >> ~/.bashrc
  • reload the shell
source ~/.bashrc
  • checking ROS2 installation
rosversion –d
printenv | grep -i ROS
  • you should able to see:
    ROS_VERSION=2
    ROS_PYTHON_VERSION=3
    ROS_DISTRO=

Testing ROS2

  • Open new terminal (Ctr + Alt + T)
ros2 run demo_nodes_cpp talker
  • Open another terminal (Ctr + Alt + T)
ros2 run demo_nodes_py listener